package com.aimashi.controller;

import com.aimashi.common.BaseResponse;
import com.aimashi.common.ErrorCode;
import com.aimashi.common.ResultUtils;
import com.aimashi.exception.BusinessException;
import com.aimashi.model.dto.questionsubmit.QuestionSubmitAddRequest;
import com.aimashi.model.dto.questionsubmit.QuestionSubmitQueryRequest;
import com.aimashi.model.entity.QuestionSubmit;
import com.aimashi.model.entity.User;
import com.aimashi.model.vo.QuestionSubmitVO;
import com.aimashi.service.QuestionSubmitService;
import com.aimashi.service.UserService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 题目提交接口
 *
 */
@RestController
//@RequestMapping("/question_submit")
@Slf4j
public class QuestionSubmitController {

//    @Resource
//    private QuestionSubmitService questionSubmitService;
//
//    @Resource
//    private UserService userService;
//
//    /**
//     * 题目提交
//     *
//     * @param questionSubmitAddRequest
//     * @param request
//     * @return 提交记录的id
//     */
//    @PostMapping("/")
//    public BaseResponse<Long> doQuestionSubmit(@RequestBody QuestionSubmitAddRequest questionSubmitAddRequest,
//            HttpServletRequest request) {
//        if (questionSubmitAddRequest == null || questionSubmitAddRequest.getQuestionId() <= 0) {
//            throw new BusinessException(ErrorCode.PARAMS_ERROR);
//        }
//        // 登录才能点赞
//        final User loginUser = userService.getLoginUser(request);
////        long questionId = questionSubmitAddRequest.getQuestionId();
//        long questionSubmitId = questionSubmitService.doQuestionSubmit(questionSubmitAddRequest, loginUser);
//        return ResultUtils.success(questionSubmitId);
//    }
//
//    /**
//     * 分页查询问题提交列表
//     * 该方法接收一个分页查询请求对象，用于指定当前页码和页面大小，并返回相应分页数据
//     * 通过HTTP Post请求方式访问/list/page路径
//     *
//     * @param questionSubmitQueryRequest 包含查询条件、当前页码和页面大小的请求对象
//     * @param request HTTP请求对象，用于获取登录用户信息
//     * @return 返回一个基础响应对象，包含分页的问题提交列表
//     */
//    @PostMapping("/list/page")
//    public BaseResponse<Page<QuestionSubmitVO>> listQuestionSubmitByPage(@RequestBody QuestionSubmitQueryRequest questionSubmitQueryRequest,
//                                                                         HttpServletRequest request){
//        // 获取当前页码
//        long current = questionSubmitQueryRequest.getCurrent();
//        // 获取页面大小
//        long size = questionSubmitQueryRequest.getPageSize();
//        // 根据当前页码和页面大小，分页查询问题提交记录
//        Page<QuestionSubmit> questionSubmitPage = questionSubmitService.page(new Page<>(current, size),
//                questionSubmitService.getQueryWrapper(questionSubmitQueryRequest));
//        // 获取当前登录用户信息
//        final User loginUser = userService.getLoginUser(request);
//        // 将分页查询的结果转换为VO（View Object）并封装到成功响应中返回
//        return ResultUtils.success(questionSubmitService.getQuestionSubmitVOPage(questionSubmitPage, loginUser));
//    }


}
